waitUntil {((alive player) or (local server))};

if(local server and !local player)then{dedicatedServer = true};	
if(local server and local player)then{hostedServer = true};

// IT IS IMPORTANT TO KEEP THIS ARRAY LIST UP TO DATE WITH ALL CIVS + COPS IN THEIR RESPECTIVE ARRAYS!
// OTHER SCRIPTS INSIDE THE MISSION MAKE CALLS TO THESE GLOBAL ARRAYS.
// IF THERE ARE MISSING LINKS, SHOPS AND SO ON WILL NOT WORK CORRECTLY!
//
// MAINLY WATCH THE STANDARD CIV/COP ARRAYS, CUSTOM SLOT ARRAYS NOT AS DEPENDED UPON.
//
// Thanks, 
// Aftermath.

playerstringarray = ["Civ1","Civ2","Civ3","Civ4","Civ5","Civ6","Civ7","Civ8","Civ9","Civ10","Civ11","Civ12","Civ13","Civ14","Civ15","Civ16","Civ17","Civ18","Civ19","Civ20","Civ21","Civ22","Civ23","Civ24","Civ25","Civ26","Civ27","Civ28","Civ29","Civ30","civ31","civ32","civ33","Civ34","Civ35","Civ36","Civ37","Civ38","Civ39","Civ40","Civ41","Civ42","Civ43","Civ44","Civ45","Civ46","Civ47","Civ48","Civ49","Cop1","Cop2","Cop3","Cop4","Cop5","Cop6","Cop7","Cop8","Cop9","Cop10","Cop11","Cop12","Cop13","Cop14","Cop15","Cop16","Cop17","Cop18","Cop19","cop20","cop21","cop22","cop23","cop24","cop25","cop26","cop27","cop28","cop29","cop30","Cop31","Cop32","Cop33","Cop34","Cop35","Cop36","Cop37","Cop38","Cop39","Cop40","cop41"];

for [{_i=0}, {_i < (count playerstringarray)}, {_i=_i+1}] do {if (isNil (playerstringarray select _i)) then { call compile format["%1 = objNull;", (playerstringarray select _i)]; }; };

playerarray = [civ1,civ2,civ3,civ4,civ5,civ6,civ7,civ8,civ9,civ10,civ11,civ12,civ13,civ14,civ15,civ16,civ17,civ18,civ19,civ20,civ21,civ22,civ23,civ24,civ25,civ26,civ27,civ28,civ29,civ30,civ31,civ32,civ33,civ34,civ35,civ36,civ37,civ38,civ39,civ40,civ41,civ42,civ43,civ44,civ45,civ46,civ47,civ48,civ49,cop1,cop2,cop3,cop4,cop5,cop6,cop7,cop8,cop9,cop10,cop11,cop12,cop13,cop14,cop15,cop16,cop17,cop18,cop19,cop20,cop21,cop22,cop23,cop24,cop25,cop26,cop27,cop28,cop29,cop30,cop31,cop32,cop33,cop34,cop35,cop36,cop37,cop38,cop39,cop40,cop41];
civstringarray    = ["Civ1","Civ2","Civ3","Civ4","Civ5","Civ6","Civ7","Civ8","Civ9","Civ10","Civ11","Civ12","Civ13","Civ14","Civ15","Civ16","Civ17","Civ18","Civ19","Civ20","Civ21","Civ22","Civ23","Civ24","Civ25","Civ26","Civ27","Civ28","Civ29","Civ30","civ31","civ32","civ33","Civ34","Civ35","Civ36","Civ37","Civ38","Civ39","Civ40","Civ41","Civ42","Civ43","Civ44","Civ45","Civ46","Civ47","Civ48","Civ49"];
civarray          = [civ1,civ2,civ3,civ4,civ5,civ6,civ7,civ8,civ9,civ10,civ11,civ12,civ13,civ14,civ15,civ16,civ17,civ18,civ19,civ20,civ21,civ22,civ23,civ24,civ25,civ26,civ27,civ28,civ29,civ30,civ31,civ32,civ33,civ34,civ35,civ36,civ37,civ38,civ39,civ40,civ41,civ42,civ43,civ44,civ45,civ46,civ47,civ48,civ49];
copstringarray    = ["Cop1","Cop2","Cop3","Cop4","Cop5","Cop6","Cop7","Cop8","Cop9","Cop10","Cop11","Cop12","Cop13","Cop14","Cop15","Cop16","Cop17","Cop18","Cop19","cop20","cop21","cop22","cop23","cop24","cop25","cop26","cop27","cop28","cop29","cop30","Cop31","Cop32","Cop33","Cop34","Cop35","Cop36","Cop37","Cop38","Cop39","Cop40","cop41"];
//THE ARRAY OF ALL THE COPS
coparray           = [cop1,cop2,cop3,cop4,cop5,cop6,cop7,cop8,cop9,cop10,cop11,cop12,cop13,cop14,cop15,cop16,cop17,cop18,cop19,cop20,cop21,cop22,cop23,cop24,cop25,cop26,cop27,cop28,cop29,cop30,cop31,cop32,cop33,cop34,cop35,cop36,cop37,cop38,cop39,cop40,cop41];
//PATROL Officer Slots
patrolwhitelist    = [cop9,cop10,cop11,cop12,cop31,cop32,cop33,cop34];
//SWAT Officer Slots
swatmemberarray	   = [cop13,cop14,cop15,cop16,cop17,cop18,cop19,cop20,cop21];
//Sherriff Slots
copadminslots	   = [cop22,cop23,cop24,cop25];
//Special Officer Slots
specialofficerarray	   = [civ41,civ42,civ43,civ44,civ45,civ46];
//ESU Slots
esuarray		   = [civ29,civ30,civ31,civ32,civ33,civ34,civ35,civ36,civ37];
//Elected Official Slots
electedarray       = [Civ1];
//Custom Slot- Applebee
custom1array       = [cop12,civ49];
//Custom Slot- Garrett
custom2array       = [Cop40];
//Custom Slot- Putzin
custom3array       = [Civ29];
//Custom Slot- P4
custom4array       = [Civ37];
//Custom Slot- Mav
custom5array       = [Civ35];
//Custom Slot- P3
custom6array       = [Civ36];
//Custom Slot- Janjko
custom7array       = [civ48];
//Custom Slot- Enzo
custom8array       = [civ47];

adminallowedarray  = [
"99907590",
"47693382",
"110079622",
"107232070",
"107982278",
"75218374",
"92966982",
"17384262", //Taryn
"3343430", //Thompson
"21827270" //Sticky
];

swatallowedarray   = [  
"99907590",
"47693382",
"107982278",
"119671110",
"92966982",
"110079622",
"107232070",
"107274950",
"8468934",
"3260742",
"21827270",
"36695238",
"65021510", //Sixta
"101359046", //Zach
"127071430", //Talamander
"69436870", //Applebee
"124007174", //Enzo
"75218374" //Kellee
];

patrolallowedarray = [
"99907590",
"47693382",
"107982278",
"119671110",
"92966982",
"110079622",
"107232070",
"125184454",
"69436870",
"107274950",
"101359046",
"21827270",
"75218374",
"135046598",
"45813894",
"10269302",
"8468934",
"127071430",
"3260742",
"36695238",
"4587846", //Noobifyed
"129546502", //Lawless
"109288646", //DemonHunter
"65021510", //Sixta
"96551366", //Mark
"99180998", //Kyle
"149141382", //TheKiller
"45875846", //Noobifyd
"136863238", //McGoorty
"3343430", //Thompson
"17384262", //Taryn
"139836742", //RJ
"6049600", //Collins
"39326150", //Noah
"140287046", //Hinkley
"99719366" //Verse
];

specialofficerallowed  = [
"99907590",
"47693382",
"110079622",
"107232070",
"107982278",
"75218374",
"92966982"
];

electedallowedarray = [
"99907590",
"107982278",
"46152006" //Bauer
];

custom1allowedarray = [
"99907590",
"107982278",
"69436870" //Applebee
];

custom2allowedarray = [
"99907590",
"107982278",
"98845894" //Garrett
];

custom3allowedarray = [
"99907590",
"107982278",
"86291654" //Putzin
];

custom4allowedarray = [
"99907590",
"107982278",
"75218374",
"79829446" //P4
];

custom5allowedarray = [
"99907590",
"107982278",
"75218374",
"88623302" //Mav
];

custom6allowedarray = [
"99907590",
"107982278",
"75218374",
"79830982" //P3
];

custom7allowedarray = [
"99907590",
"107982278",
"75218374",
"48016902" //Janjko
];

custom8allowedarray = [
"99907590",
"107982278",
"75218374",
"124007174" //Enzo
];


rolenumber = 0; 

for [{_i=0}, {_i < (count playerarray)}, {_i=_i+1}] do 

{ 

call compile format["if ((playerarray select %1) == player) then {rolenumber = (%1 + 1);}", _i];

};

role = player;
	

if (player in coparray) then 

{
										
iscop          = true;
isswat		   = false;
isciv	       = false;							
rolecop        = 1;								
sidenumber     = rolenumber - civscount;			
longrolenumber = 1100 + sidenumber;			
rolestring     = format["Cop%1", sidenumber];

};

_civnum = player;
{
	if (_civnum == _x) then

	{

	isswat = true;
	iscop  = true;
	isciv  = false;

	};
} foreach swatmemberarray;

if (player in civarray) then 

{

isciv          = true;						
iscop          = false;	
isswat		   = false;											
rolecop        = 0;								
sidenumber     = rolenumber;				
longrolenumber = 1000 + sidenumber;										
rolestring     = format["Civ%1", sidenumber];

};




if (typeName player == "OBJECT") then {
	if (!isNull player) then {
		call compile format["old%1 = objnull", player];
	};
};

	_uid  = getPlayerUID player;
	_civnum = player;
	
{
	if (_civnum == _x) then
	{
		if !(_uid in adminallowedarray) then
		{
			player groupChat "This slot is reserved for ArcLight Administrators! You will be kicked back to lobby in 10 seconds!";
			sleep 10;
			failMission "END1";
		}
		else
		{
			player groupChat "ArcLight Entertainment welcomes you to Island Life: Miami Vice. You have been logged in as an Administrator."
		};
	};
} foreach copadminslots;
	
	
{
	if (_civnum == _x) then
	{
		if !(_uid in patrolallowedarray) then
		{
			player groupChat "This slot is reserved for trained Patrol Officers! You will be kicked back to lobby in 10 seconds!";
			sleep 10;
			failMission "END1";
		}
		else
		{
			player groupChat "ArcLight Entertainment welcomes you to Island Life: Miami Vice. You have been logged in as a trained Patrol Officer."
		};
	};
} foreach patrolwhitelist;

{
	if (_civnum == _x) then
	{
		if !(_uid in swatallowedarray) then
		{
			player groupChat "This slot is reserved for trained SWAT Officers! You will be kicked back to lobby in 10 seconds!";
			sleep 10;
			failMission "END1";
		}
		else
		{
			player groupChat "ArcLight Entertainment welcomes you to Island Life: Miami Vice. You have been logged in as a trained SWAT Officer."
		};
	};
} foreach swatmemberarray;

{
	if (_civnum == _x) then
	{
		if !(_uid in specialofficerallowed) then
		{
			player groupChat "This slot is reserved for trained SWAT Officers! You will be kicked back to lobby in 10 seconds!";
			sleep 10;
			failMission "END1";
		}
		else
		{
			player groupChat "ArcLight Entertainment welcomes you to Island Life: Miami Vice. You have been logged in as a trained SWAT Officer."
		};
	};
} foreach specialofficerarray;

{
	if (_civnum == _x) then
	{
		if !(_uid in electedallowedarray) then
		{
			player groupChat "This slot is reserved for Elected Officials! You will be kicked back to lobby in 10 seconds!";
			sleep 10;
			failMission "END1";
		}
		else
		{
			player groupChat "ArcLight Entertainment welcomes you to Island Life: Miami Vice. You have been elected as an official politician of the State."
		};
	};
} foreach electedarray;

{
	if (_civnum == _x) then
	{
		if !(_uid in custom1allowedarray) then
		{
			player groupChat "This slot is reserved for Patrol Sergeant Applebee! You will be kicked back to lobby in 10 seconds!";
			sleep 10;
			failMission "END1";
		}
		else
		{
			player groupChat "Welcome to Island Life: Miami Vice Patrol Sergeant Applebee."
		};
	};
} foreach custom1array;

{
	if (_civnum == _x) then
	{
		if !(_uid in custom2allowedarray) then
		{
			player groupChat "This slot is reserved for Patrol Officer Garrett! You will be kicked back to lobby in 10 seconds!";
			sleep 10;
			failMission "END1";
		}
		else
		{
			player groupChat "Welcome to Island Life: Miami Vice Patrol Officer Garrett."
		};
	};
} foreach custom2array;

{
	if (_civnum == _x) then
	{
		if !(_uid in custom3allowedarray) then
		{
			player groupChat "This slot is reserved for ArcLight Member Putzin! You will be kicked back to lobby in 10 seconds!";
			sleep 10;
			failMission "END1";
		}
		else
		{
			player groupChat "Welcome to Island Life: Miami Vice ArcLight Member Putzin."
		};
	};
} foreach custom3array;

{
	if (_civnum == _x) then
	{
		if !(_uid in custom4allowedarray) then
		{
			player groupChat "This slot is reserved for ArcLight Member P4! You will be kicked back to lobby in 10 seconds!";
			sleep 10;
			failMission "END1";
		}
		else
		{
			player groupChat "Welcome to Island Life: Miami Vice ArcLight Member P4."
		};
	};
} foreach custom4array;

{
	if (_civnum == _x) then
	{
		if !(_uid in custom5allowedarray) then
		{
			player groupChat "This slot is reserved for ArcLight Member Mav! You will be kicked back to lobby in 10 seconds!";
			sleep 10;
			failMission "END1";
		}
		else
		{
			player groupChat "Welcome to Island Life: Miami Vice ArcLight Member Mav."
		};
	};
} foreach custom5array;

{
	if (_civnum == _x) then
	{
		if !(_uid in custom6allowedarray) then
		{
			player groupChat "This slot is reserved for ArcLight Member P3! You will be kicked back to lobby in 10 seconds!";
			sleep 10;
			failMission "END1";
		}
		else
		{
			player groupChat "Welcome to Island Life: Miami Vice ArcLight Member P3."
		};
	};
} foreach custom6array;

{
	if (_civnum == _x) then
	{
		if !(_uid in custom7allowedarray) then
		{
			player groupChat "This slot is reserved for ArcLight Member Janjko! You will be kicked back to lobby in 10 seconds!";
			sleep 10;
			failMission "END1";
		}
		else
		{
			player groupChat "Welcome to Island Life: Miami ArcLight Member Janjko."
		};
	};
} foreach custom7array;

{
	if (_civnum == _x) then
	{
		if !(_uid in custom8allowedarray) then
		{
			player groupChat "This slot is reserved for ArcLight Member Enzo! You will be kicked back to lobby in 10 seconds!";
			sleep 10;
			failMission "END1";
		}
		else
		{
			player groupChat "Welcome to Island Life: Miami ArcLight Member Enzo."
		};
	};
} foreach custom8array;